package pokeronlab_2014.mcts;

import pokeronlab_2014.Controller;
import pokeronlab_2014.SVMClassifierData;
import pokeronlab_2014.mcts.TreeNode.NodeType;

public class OpponentNode extends PlayerNode {
	
	
	public TreeNode selectNoFold(TreeNode currentNode){
		Controller.debugWindow.printMessage("ide nem kéne bekerülini:OpponentNode.selectNoFold");
		return currentNode;
	}
	
	public OpponentNode() {
		//Controller.debugWindow.printMessage("OpponentNode.OpponentNode");
		parent = null;
		SVMbemenet = new SVMClassifierData();
		typeOfNode = NodeType.playeraction_other;
		nVisits = 0;
		totValue = 0;
	}

	public TreeNode simulate(TreeNode currentNode){

		//currentNode.typeOfNode= NodeType.playeraction_other;
		

		
		int index = (int)(Math.random()*3);

			
		
//		if(index==0)
//			Controller.debugWindow.printMessage("muhahaha");
		
		if(rules.nextplayer(rules.actualplayer, index)==-1){
			//Controller.debugWindow.printMessage("ide nem kéne bekerülini:OpponentNodeS.simulate");
			children = new TreeNode[nCard];
		}
		else
			children = new TreeNode[nActions];
		
		if(rules.nextplayer(rules.actualplayer, index)==rules.myseat)
			children[index] = new BotNode();
		else
			if(rules.nextplayer(rules.actualplayer, index)==-1)
				children[index] = new CardNode();
			else
				children[index] = new OpponentNode();
		
		currentNode = currentNode.children[index];
		if(index==0)
			currentNode.creatNode(this,index, rules.getPlayerID(rules.nextplayer(rules.actualplayer, index)), 0, level);
		if(index==1)
			currentNode.creatNode(this,index, rules.getPlayerID(rules.nextplayer(rules.actualplayer, index)), rules.amunttocall(rules.actualplayer), level);
		if(index==2)
			if(rules.round<2)
				currentNode.creatNode(this,index, rules.getPlayerID(rules.nextplayer(rules.actualplayer, index)), rules.amunttocall(rules.actualplayer)+rules.fixlimit, level);
			else
				currentNode.creatNode(this,index, rules.getPlayerID(rules.nextplayer(rules.actualplayer, index)), rules.amunttocall(rules.actualplayer)+2*rules.fixlimit, level);

	
		//Controller.debugWindow.printMessage("OpponenetNode.simulate");
		
		
//		currentNode = currentNode.children[OP.getResponse(SVMbemenet,
//				Controller.thisGameInfo
//						.getPlayerName(Controller.thisGameInfo
//								.getCurrentPlayerSeat()))];
		//meghívást át kell írni TODO
		
		return currentNode;
	}
}
